/**
 * @brief: 
 *
 * @author: dariaye@tencent.com
 * @date: 2012-8-13
 * @version: 1.0
 * @changes:
 *    <author>        <time>        <version >        <desc>
 *     dariaye             2012-8-13              1.0                 Create
 *
 */

#ifndef WALLE_COMMON_CRITICAL_SECTION_H
#define WALLE_COMMON_CRITICAL_SECTION_H

#include "global_def.h"

class CriticalSection
{
public:
    CriticalSection();
    virtual ~CriticalSection();

    bool Init(WLUInt capacity);
    void UnInit();

    void Lock(WLUInt index);
    void UnLock(WLUInt index);

protected:
    int TestAndSet(unsigned char* addr);

    unsigned char* m_critical_data;
    WLUInt m_capacity;
};

#endif /* WALLE_COMMON_CRITICAL_SECTION_H */
